cd /d %~dp0

set protocol=%1
set port=%2
netstat -nao | grep -Pi "%protocol%\s+[0\.\[:\]]+:%port%\D" | wc -l >portcount.out

set /p portcount=<portcount.out
echo portcount=%portcount%
del portcount.out /q